#include <gmock/gmock.h>
#include <gtest/gtest.h>

#include <algorithm>  // for std::ranges::copy depending on lib support
#include <iostream>
#include <iterator>
#include <numeric>
#include <string>
#include <vector>

using namespace testing;

TEST(PrintTest, should_print_with_range)
{
    std::vector<char> path{'/', 'f', 'o', 'o'};

    //在gcc里下面这行才会执行成功
    std::ranges::copy(path, std::ostream_iterator<char>(std::cout, " "));
}

struct TestDataClass {
    int age;
    std::string name;
    TestDataClass(int age, std::string name):age(age), name(name) { 
        
     }
    friend std::ostream& operator<<(std::ostream& os, const TestDataClass& obj)
    {
        os << obj.age << " " << obj.name;
        return os;
    }
};


TEST(PrintTest, should_print_custom_class_with_range)
{
    std::vector<TestDataClass> data_list{TestDataClass(18,"Tom"), TestDataClass(20,"Jerry")};
    std::ranges::copy(data_list, std::ostream_iterator<TestDataClass>(std::cout, " "));
}
